<?php

namespace App\Http\Requests\Admin;

use Illuminate\Foundation\Http\FormRequest;

class UserRequest extends FormRequest
{
    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules(): array
    {
        if ($this->isMethod('POST')) {
            return [
                'group_id' => 'bail|required|integer',
                'nickname' => 'bail|required|integer|unique:user,nickname',
                'level' => 'bail|required|integer',
                'gender' => 'bail|required|integer',
                'money' => 'bail|required|numeric',
                'score' => 'bail|required|numeric',
            ];
        } elseif ($this->isMethod('PUT')) {
            return [
                'group_id' => 'bail|required|integer',
                'username' => 'bail|nullable|string|unique:user,username',
                'nickname' => 'bail|required|string|unique:user,nickname',
                'mobile' => 'bail|required|mobile|unique:user,mobile',
                'level' => 'bail|required|integer',
                'gender' => 'bail|required|integer',
                'money' => 'bail|required|numeric',
                'score' => 'bail|required|numeric',
                'status' => 'bail|required|string|in:normal,ban'
            ];
        }else {
            return [];
        }
    }
}
